<template>
  <div>
    <avue-group label="现金事务">
      <avue-crud
        :data="crashWorkList"
        :option="crashWorkTbleOption"
      ></avue-crud>
    </avue-group>
    <avue-group label="电子事务">
      <avue-crud
        :data="electronWorkList"
        :option="electronWorkTbleOption"
      ></avue-crud>
    </avue-group>
    <avue-group label="付费出站发售事务">
      <avue-crud :data="payWorkList" :option="payWorkTableOption"></avue-crud>
    </avue-group>
    <avue-group label="特殊车票发售事务">
      <avue-form
        ref="specialform"
        v-model="specialWorkForm"
        :option="specialWorkFormOption"
      ></avue-form>
    </avue-group>
    <avue-group label="免费出站发售事务">
      <avue-form
        ref="freeform"
        v-model="freeWorkForm"
        :option="freeWorkFormOption"
      ></avue-form>
    </avue-group>
    <avue-group label="故障退款事务">
      <avue-crud
        :data="refundWorkList"
        :option="refundWorkTableOption"
      ></avue-crud>
    </avue-group>
    <avue-group label="乘客事务退换票">
      <avue-crud
        :data="ticketWorkList"
        :option="ticketWorkTableOption"
      ></avue-crud>
    </avue-group>
    <avue-group label="其他运营商退票数据录入">
      <avue-crud
        :data="otherWorkList"
        :option="otherWorkTableOption"
      ></avue-crud>
    </avue-group>
    <!-- <div class="bottom-menu">
      <el-button type="primary" @click="submit" :loading="isSubmit"
        >一键确认</el-button
      >
    </div> -->
  </div>
</template>

<script>
import {
  getNeedConfirmData,
  confirm
} from "@/api/subwaystm/swstinputpassengerworkconfirm";
import { checkPwd } from "@/api/admin/user";
import { dateFormat } from "@/util/date";
export default {
  name: "passenger-work-confirm",
  data() {
    return {
      searchForm: {
        startTime: dateFormat(new Date()).substr(0, 10)
      },
      marketingTicket: {},
      crashWorkList: [],
      electronWorkList: [],
      payWorkList: [],
      specialWorkForm: {},
      freeWorkForm: {},
      refundWorkList: [],
      ticketWorkList: [],
      otherWorkList: [],
      crashWorkTbleOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            type: "select",
            label: "事件详情",
            prop: "eventDetail",
            dicUrl: "/admin/dict/type/cash_work_event_detail"
          }, {
            label: '处理结果',
            prop: 'handleResult',
          }, {
              type: "input",
              label: "金额",
              prop: "amount"
          },{
            label: 'POS交易类型',
            prop: 'posType',
            type: 'select',
            dicUrl: '/admin/dict/type/cash_work_pos_type'
          },{
	    label: '票种',
	    prop: 'ticketType',
	    type: 'select',
	    dicUrl: '/support/swpmticketcardtype/dict/ticketPosCash',
	    props: {
		label: 'mainName',
		value: 'mainEnName'
	      },
	     width: 130
	   },{
	      label: '车票名称',
	      prop: 'ticketSubType',
	      type: 'select',
	      dicUrl: '/support/swpmticketcardtypeparam/dictAll/{{key}}',
	      props: {
	      label: 'subName',
	      value: 'subEnName'
	      },
	      width: 130

	    },{
	      label: '数量',
	      prop: 'posSum',
	      type: 'number'
            },{
	      "type": "select",
	      "label": "POS卡类型",
	      "prop": "posCardType",
	       dicUrl:'/admin/dict/type/pos_card_type' ,
	       width: 180
	    }
        ]
      },
      electronWorkTbleOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            type: "input",
            label: "事件详情",
            prop: "eventDetail",
            dicUrl: "/admin/dict/type/ele_work_event_detail"
          },
          {
            type: "input",
            label: "金额",
            prop: "amount"
          }
        ]
      },
      payWorkTableOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            type: "input",
            label: "事件详情",
            prop: "eventDetail",
            dicUrl: "/admin/dict/type/pay_work_event_type"
          },
          {
            type: "input",
            label: "张数",
            prop: "sellNumber"
          },
          {
            type: "input",
            label: "金额",
            prop: "amount"
          },
          {
            type: "input",
            label: "备注",
            prop: "remark"
          }
        ]
      },
      specialWorkFormOption: {
        menuBtn: false,
        detail: true,
        labelWidth: 130,
        column: [
          {
            label: "现役军人、武警、消防员发放张数",
            prop: "soliderNumber",
            type: "number",
            span: 6,
          },
          {
            label: "离退休干部士官、部分优抚对象发放张数",
            prop: "f1",
            type: "number",
            span: 6,
          },
	  // {
    //         label: "现役军人、武警、消防员专窗张数",
    //         prop: "f3",
    //         type: "number",
    //         span: 6,
    //       },
	  {
            label: "残疾人等发放张数",
            prop: "f2",
            type: "number",
            span: 6,
          },

          {
            label: "其他情况发放张数",
            prop: "otherNumber",
            type: "number",
            span: 6,
          },
          {
            label: "合计销售张数",
            prop: "sellNumber",
            type: "number",
            span: 6,
          }/*,
          {
            label: "上传截图",
            span: 24,
            prop: "filePath",
            type: "upload",
            component: "zd-upload",
            listType: "picture-img"
          }*/
        ]
      },
      freeWorkFormOption: {
        menuBtn: false,
        detail: true,
        labelWidth: 130,
        column: [
          {
            label: "闸门被误用张数",
            prop: "gateMisuseNumber",
	    span: 6
          },
	  {
            label: "手机无电张数",
            prop: 'mobileNoeleNumber',
            span: 6
          },
          {
            label: "车票非人损张数",
            prop: "ticketDamageNumber",
	    span: 6
          },
          {
            label: "其他张数",
            prop: "otherNumber",
	    span: 6
          },
          {
            label: "合计",
            prop: "total",
	    span: 6
          }/*,
          {
            label: "上传截图",
            span: 24,
            prop: "filePath",
            type: "upload",
            component: "zd-upload",
            listType: "picture-img"

          }*/
        ]
      },
      refundWorkTableOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: "事件详情",
            prop: "failureOperator",
            type: "select",
            dicUrl: "/admin/dict/type/stm_failure_operator"
          },
          {
            label: "故障次数",
            prop: "failureTimes",
            type: "number"
          },
          {
            label: "退款金额",
            prop: "amountRefunded",
            type: "number",
            precision: 2
          }/*,
          {
            label: "上传截图",
            prop: "filePath",
            type: "upload",
            component: "zd-upload"

          }*/
        ]
      },
      ticketWorkTableOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: "操作类型",
            prop: "operationType",
            dicUrl: "/admin/dict/type/work_ticket_operation_type"
          },
          {
            label: "办理类型",
            prop: "handleType",
            dicUrl: "/admin/dict/type/work_ticket_handle_type"
          },{
            label: '票种',
            prop: 'ticketType',
            type: 'select',
            cascaderItem: ["ticketName"],
            dicUrl: '/support/swpmticketcardtype/dict',
            props: {
              label: 'mainName',
              value: 'mainEnName'
            }
          },{
            label: '车票名称',
            prop: 'ticketName',
            type: 'select',
            props: {
              label: 'subName',
              value: 'subEnName'
            },
            dicUrl: '/support/swpmticketcardtypeparam/dictAll/{{key}}',
            dicFlag: false
          },
          {
            label: "旧卡号/订单号",
            prop: "cardOrder"
          },
          {
            label: "替换卡号/商户号",
            prop: "replaceCardOrder"
          },{
            label: '替换票种',
            prop: 'replaceTicketType',
            type: 'select',
            cascaderItem: ["replaceTicketName"],
            dicUrl: '/support/swpmticketcardtype/dict',
            props: {
              label: 'mainName',
              value: 'mainEnName'
            }
          },{
            label: '替换车票名称',
            prop: 'replaceTicketName',
            type: 'select',
            props: {
              label: 'subName',
              value: 'subEnName'
            },
            dicUrl: '/support/swpmticketcardtypeparam/dictAll/{{key}}',
            dicFlag: false
          },
          {
            label: "金额",
            prop: "amount"
          },
          {
            label: "办理时间",
            prop: "handleTime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss"
          }
        ]
      },
      otherWorkTableOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: '(故障/发售)运营商',
            prop: 'failureOperator',
            type: 'select',
            dicUrl: '/admin/dict/type/work_other_failure_operator',
            width: 150
          },  {
            label: '进/出站',
            prop: 'sellOperator',
            type: 'input',
            width: 150
          },
	        {
            "type": "select",
            "label": "数据类型",
            "prop": "dataType",
            dicUrl: '/support/swpmworkotherdatatype/dict',
            props: {
              label: 'mainName',
              value: 'mainDataValue'
            },
            cascaderItem: ["happenCause"],
            width: 120
          },	  {
            "type": "select",
            "label": "产生原因",
            "prop": "happenCause",
            dicFlag: false,
            props: {
              label: 'subName',
              value: 'subDataValue'
            },
            dicUrl: '/support/swpmworkotherhappencause/dict/{{key}}',
            width: 200
          },
          // {
          //   type: "select",
          //   label: "产生原因",
          //   prop: "happenCause",
          //   dicUrl: "/admin/dict/type/stm_other_happen_cause"
          // },
          // {
          //   type: "select",
          //   label: "数据类型",
          //   prop: "dataType",
          //   dicUrl: "/admin/dict/type/stm_other_data_type"
          // },
          {
            label: "张数",
            prop: "ticketNumber"
          },
          {
            label: "金额",
            prop: "amount"
          },
          {
            label: "录入时间",
            prop: "inputTime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss"
          }
        ]
      },
      isSubmit: false
    };
  },
  computed: {},
  methods: {
    getData(searchForm) {
      getNeedConfirmData({
        startTime: searchForm.date,
        classNumber: searchForm.nsShift,
        conductorCode: searchForm.nsJobNo
      }).then(response => {
        var result = response.data.data || {};
        this.crashWorkList = result.crash_work || [];
        this.electronWorkList = result.electron_work || [];
        this.payWorkList = result.pay_work || [];
        this.specialWorkForm = result.special_work[0] || this.$refs.specialform.resetFields();
        this.freeWorkForm = result.free_work[0] || this.$refs.freeform.resetFields();
        this.refundWorkList = result.refund_work || [];
        this.ticketWorkList = result.ticket_work || [];
        this.otherWorkList = result.other_work || [];
      });
    }
    // submit() {
    //   if (!this.searchForm.conductorCode) {
    //     this.$message.info("请选择售票员");
    //     return;
    //   }
    //   this.isSubmit = true;
    //   this.$prompt("请输入售票员密码", "确认", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     inputType: "password",
    //     inputValidator: val => {
    //       if (!val) return "请输入密码";
    //     }
    //   })
    //     .then(({ value }) => {
    //       return checkPwd(this.searchForm.conductorCode, value);
    //     })
    //     .then(response => {
    //       var result = response.data.data;
    //       if (result) {
    //         return;
    //       } else {
    //         this.$message.error("密码错误");
    //         return Promise.reject("密码错误");
    //       }
    //     })
    //     .then(() => {
    //       let passengerWorkIds = [
    //         ...this.crashWorkList.map(w => w.relationId),
    //         ...this.electronWorkList.map(w => w.relationId),
    //         ...this.payWorkList.map(w => w.relationId),
    //         ...this.refundWorkList.map(w => w.relationId)
    //       ];
    //       if (this.specialWorkForm.relationId)
    //         passengerWorkIds.push(this.specialWorkForm.relationId);
    //       if (this.freeWorkForm.relationId)
    //         passengerWorkIds.push(this.freeWorkForm.relationId);
    //       passengerWorkIds = Array.from(new Set(passengerWorkIds));
    //       let ticketWorkIds = this.ticketWorkList.map(w => w.id);
    //       let otherWorkIds = this.otherWorkList.map(w => w.id);
    //       return confirm({ passengerWorkIds, ticketWorkIds, otherWorkIds });
    //     })
    //     .then(() => {
    //       this.getData();
    //       this.$message.success("确认成功");
    //       this.isSubmit = false;
    //     })
    //     .catch(error => {
    //       console.log(error);
    //       this.isSubmit = false;
    //     });
    // }
  }
};
</script>

<style lang="scss" scoped>
.bottom-menu {
  text-align: center;
}
</style>
